{% extends "base.html"%}

{% block body %}
<script>
$(document).ready(function(){
    $("#project_list dd").click(function(){
        $("#project_list .ddclick").removeClass("ddclick");
        
        $(this).addClass("ddclick");
        $("#chield_name").text($(this).text())
   
    });
    
    /*新建项目*/
    $(".newproj").click(function(){
        $.get('/jobs/proj_add', function(data) {  
            $("#content_box").html(data);
        });  
    })
    
    $.get("/jobs/{{proj_id}}/const_cate_all",function(data){
        $("#content_box").html(data);
        $(".right_list").show();
        $(".right_edit").hide();
    });
	reSizeLayout();
});

$(window).resize(function(){
	//alert( " width "+$(window).width()); //浏览器时下窗口可视区域宽度 
//	alert("document.width" + $(document).width());//浏览器时下窗口文档对于象宽度 
//	alert("document.body.width " + $(document.body).width());//浏览器时下窗口文档body的高度 
	reSizeLayout();

});

function reSizeLayout(){
	if($(document.body).width() <=400 ){
		$("#layout_left").hide();
	}else{
		$("#layout_left").show();
	}
}


function NewTask(obj){
    if ($(obj).attr("contentEditable") == "false"  ){
        $(obj).attr("contentEditable", "true");
        $(obj).focus();
        old_html = $(obj).html();
        $(obj).html("");
        onkeydown = function(e){

            $(obj).off("keydown",onkeydown);
            if ($(obj).attr("contentEditable") == "false"  ){
                return 
            }
            if (e.which == 13 ){
                $.ajax({
                type: "POST",
                data:{"name":$(obj).text(),"csrfmiddlewaretoken":getCookie('csrftoken'),},
                url:$(obj).attr("title"), 
                success:function(data){
                    $("#AppendNewDD").append(data);
                    $(obj).html(old_html);
                    $(obj).attr("contentEditable", "false");
                    obj.onkeydown="";
                }});
                

                return false;
            }

        }
        $(obj).on("keydown",onkeydown);
        

    }
}

function quickFinish(task_id){
	var okclick=function(){
	$.ajax({
    type: "POST",
    data:{"id":task_id,"type":2,"csrfmiddlewaretoken":getCookie('csrftoken'),},
    url:"/jobs/task_quick_over", 
    success:function(data){
		alert(data);
}});
}
	$("#confirmbox").show();
	$("#confirmbox").dialog({
		buttons:{
			"这是必须的":function(){
				okclick();
				$(this).dialog("close")
			},
			"没有":function(){
				$(this).dialog("close");
			}
		}
	});

	$("#confirmbox").html("<p>我就是像确认一下你有没有点错，真的完成这个任务了么？</p>");

}


function TaskIdCheckbox(obj){
    $.ajax({
    type: "POST",
    data:{"id":$(obj).val(),"type":1,"csrfmiddlewaretoken":getCookie('csrftoken'),},
    url:"/jobs/task_quick_over", 
    success:function(data){
        if ( data=="success" ){
            $("#dd_task_id_"+$(obj).val()).remove();
        }else{
            alert(data);
        }
    }});
}
function ShowOverTask(pageurl){
	if ( $("#over_task_list").css("display") =="none" ) {
		
		$("#over_task_list").html('<strong style="color:#666666">loading.....</strong>')
		$.ajax({
			type: "GET",
			url:pageurl ,
			success:function(data){
				$("#over_task_list").html(data);
			}
		});
        $("#over_task_list").show();
    }else{
        $("#over_task_list").hide();
        
    }
}





/*获取*/
function TaskEdit(obj){
    if(  $(".right_edit").css("display") == "none" ){
        $(" .right_list").hide();
        $(".right_edit").show();
        url = "/jobs/" +$(obj).attr("id")
		$(".right_edit").html("努力加载中...");
		$.get(url,function(data){
             $(".right_edit").html(data);
			$( "#id_start_date" ).datepicker({ dateFormat: 'yy-mm-dd',monthNames:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']});

		});
    }else{
        $(".right_list").show();
        $(".right_edit").hide();

    }
}

function TaskEditPost(){
    $.ajax({
        url:$("#edit_task").attr("action"),
        data: $('#edit_task').serialize(),
        type: $('#edit_task').attr("method"),
        success:function(data){
            alert(data);
        }
    });
   
    
}


</script>
<!-- Primary Page Layout
================================================== -->

<!-- Delete everything in this .container and get started on your own site! -->
<div id="confirmbox" title="操作提示"></div>

<table border=0 width=100% >
  
    <Tr><td id="layout_left" valign="top" style="vertical-align:top;" width=180>
        
    <div class="container_left" id="project_list">
            <dl>
                <dt> 我的项目 </dt>
                {% block project_dd_list %}
      
                {% endblock %}
                <dd onclick="location.href='/jobs';">返回项目列表</dd>
            </dl>
        </div>
    <div class="container_left" id="container_left">
        <dl>
            <dt >{% block project_name %}任务分类{% endblock %}</dt>
            <dd id="const_cate_all" class="ddclick">全部</dd>
            <dd id="const_cate_time" >任务排期</dd>
            <dd id="const_cate_me" >属于我的</dd>
            <dd id="const_cate_over">已完成</dd>
            <dd id="const_cate_bug" >BUG列表</dd>
            {% block project_dd_cate %}
      
            {% endblock %}
        </dl>
    </div>
    
    <div class="container_left" >
            <dl>
                <dt> 个人操作 </dt>
                <dd onclick="location.href='/user/report/day'">日报整理</dd>
                <dd onclick="location.href='/user/report/week'">周报整理</dd>
                
                <dd onclick="location.href='/user_edit'" >用户信息修改</dd> 
                <dd onclick="location.href='/logout'">退出登录</dd>               
            </dl>
    </div>

    
	</td><td valign="top" id="layout_right">

	<div id="container_right" class="right_list">
		<div class="loading1"></div>
		<div class="title"><h3 id="chield_name" class="h3title">全部</h3></div>
        <div class="list" id="content_box">
        </div>
    </div>
    
    <div id="container_right" class="right_edit" style="">
		<div><div>分类</div><div>列表</div></div>	
		<div class="title"><h3 class="h3title">任务详细</h3></div>
        <div class="formbox" id="content_box">
        </div>
    </div>
</td></tr>
</table>
{% endblock %}
